<!DOCTYPE html>
<html lang="zh-hans">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <title>充值 </title>
    <link rel="stylesheet" href="__TEMPLATE__/webfile/main.css">
    <script type="text/javascript" src="__TEMPLATE__/sysme/js/jquery-1.9.1.min.js"></script>
     <script type="text/javascript" src="__SYSMET__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script src="__SYSMET__/lib/layer/2.4/layer.js" type="text/javascript"></script>
    <style>
        .cz_header {
            width: 96%;
            height: 30px;
            line-height: 30px;
            border: 1px solid #ccc;
            overflow: hidden;
            padding: 10px 2%;
        }

        .cz_header>div {
            float: left;
            height: 30px;
        }

        .info_money {
            width: 96%;
            padding: 0 2%;
            
        }

        .info_money p {
            height: 30px;
            line-height: 30px;
            width: 100%;
            margin-bottom: 15px;
        }

        .info_money div span {
        	width:120px;
        	display:block;
            height: 40px;
            text-align: center;
            float: left;
            font-size:16px;
            border: 1px solid #ccc;
            line-height:40px;
            border-radius: 3px;
            background:#e6e6e6;
            margin:15px 25px;
        }
       
        .info_money div .add_bg {
            background: #f00;
            color: #fff;
        }
        .xzfs {
        	
            width: 100%;
            height: auto;
            overflow: hidden;
            padding-bottom:10px;
        }
         .xzfs li {
        	width:120px;
            height: 40px;
            float: left;
            border: 2px dashed #ccc;
            border-radius: 3px;
            padding:4px 10px;
           margin:10px 20px;
            position:relative;
            overflow: hidden;
        }
        .xzfs li {
            display: block;
            overflow: hidden;
            text-decoration: none;
            color: #000;
        }
        .xzfs li h2{text-align: center;font-size:16px;}
        .xzfs li div {
            font-size: 14px;
            font-weight: bold;
        }
        .xzfs li div span{display:block;text-align: center;}
        .xzfs .unselect{
            border-color: #ccc;
        }
        .xzfs .select{
            border-color: red;
        }
        .zzc_recharge{width:100%;height:100%;min-height:650px;background:black;opacity: .3;position:absolute;top:0;display:none;z-index: 4;}
        #content{width:540px;height:auto;background:#fff;position:absolute;top:100px;left:50%;margin-left:-270px;z-index: 5;}
        a:hover{text-decoration: none;}
    </style>
</head>

<body cz-shortcut-listen="true">
<div class="header">
    <div class="main main_btm_border">
        <div class="left logo">
            <a href="{:url('index/home')}" class="logo-link">
						<span class="logo_image">
						</span>
                <style>
                    .logo_image {
                        background-image:url("__ATTACHMENT__/{$logo.logoimg}")!important
                    }
                </style>
            </a>
        </div>
        <div class="right login_and_userinfo_1">
            <div class="login_header">
						<span class="welcome">
						</span>
                <div class="mobile_download" style="cursor:pointer">
                    <i class="iconfont">
                        
                    </i>
                    <i class="iconfont">
                        
                    </i>
							<span class="">
								手机app下载
							</span>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="model_2" class="model_2" style="display:none">
    <div class="model_header">
        <h1>
            温馨提醒
        </h1>
    </div>
    <div class="model_body">
				<span id="model_content">
				</span>
    </div>
    <div class="foot_succ">
        <a onclick="jQuery.modal.close()" class="btn btn-default btn-radius">
            确定
        </a>
    </div>
</div>
<div class="main usercenter">
    <div class="user_topup">
        <div class="user_menu left">
            <h2>会员中心</h2>
            <ul>
                <li><i class="iconfont"></i>
                    <a href="{:url('user/index')}">个人中心</a>
                </li>
                <li class="hover"><i class="iconfont"></i>
                    <a class="user_goto_finance" href="{:url('user/recharge')}">财务中心</a>
                </li>
                <li><i class="iconfont"></i>
                    <a href="{:url('user/callRecord')}">交易记录</a>
                </li>
                <!-- <li><i class="iconfont"></i><a href="{:url('user/detail')}">详细设定</a></li> -->
                <li><i class="iconfont"></i>
                    <a href="{:url('user/peilvdetail')}">赔率详情</a>
                </li>
                <li><i class="iconfont"></i>
                    <a href="{:url('user/message')}">信息公告</a>
                </li>
                <li><i class="iconfont"></i><a href="{:url('user/djsm')}">等级说明</a></li>
            </ul>

            <h2>代理中心</h2>
            <ul>
                <li><i class="iconfont"></i>
                    <a class="user_goto_finance" href="{:url('user/dlCentent')}">代理说明</a>
                </li>
                {if($f.dl==1)}
                <li><i class="iconfont"></i>
                    <a href="{:url('user/dailibaobiao')}">代理报表</a>
                </li>
                <li><i class="iconfont"></i>
                    <a href="{:url('user/xiajibaobiao')}">下级报表</a>
                </li>
                <li><i class="iconfont"></i>
                    <a href="{:url('user/xiajikaihu')}">下级开户</a>
                </li>
                <!--<li><i class="iconfont"></i>
                    <a href="{:url('user/xiajiguanli')}">下级管理</a>
                </li>-->
                <li><i class="iconfont"></i>
                    <a href="{:url('user/touzhumingxi')}">投注明细</a>
                </li>
                <li><i class="iconfont"></i>
                    <a href="{:url('user/jiaoyimingxi')}">交易明细</a>
                </li>
                {else/}
                <li><i class="iconfont"></i>
                    <a href="{:url('user/shenqing')}">代理申请</a>
                </li>
                {/if}
            </ul>
        </div>
        <div class="user_right right" style="height:;">
            <div class="user_main">
                <div class="user_header">
                    <div class="user_header_nav">
                        <ul>
                            <li class="hover">
                                <a href="{:url('user/recharge')}">充值</a>
                            </li>
                            <li>
                                <a href="{:url('user/drawMoney')}">提现</a>
                            </li>
                            <li>
                                <a href="{:url('user/rechargeRecord')}">充值记录</a>
                            </li>
                            <li>
                                <a href="{:url('user/drawMoneyRecord')}">提现记录</a>
                            </li>
                            <li>
                                <a href="{:url('user/other')}">其他记录</a>
                            </li>
                            <li style="background:#fff;float:right;height:36px;margin-top:4px;margin-right:4px;font-size:12px;line-height:36px;padding:0 4px;">
                                <span style="margin-right:10px;">账&nbsp;&nbsp;号：{$user_all.username}</span>
                                <span >金额：<i style="color:red;font-style: normal">{$user_all.je}</i></span>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="user_body" style="padding:0;position:relative;min-height:650px;">
                	<div class="zzc_recharge"></div>
                	<ul class="info_money">
                        <li>
                        	
                            <p style="color:#8e8880;margin-top:20px;font-size:15px;width:100%;height:85px;overflow: hidden;">
                            	<span style="float:left;width:100%;color:#000;margin-right:10px;font-size:18px;margin-bottom:10px;">第一步：输入您要充值的金额或选择下方快捷金额:</span>
                                 <i style="display:block;border-radius:50%;float:left;width:20px;height:20px;background:red;color:#fff;font-style: normal;line-height:20px;text-align: center;margin-top:5px;margin-right:5px;">￥</i>                                                                        
                                 <span style="display:block;float:left;width:;font-size:18px;height:31px;">充值金额：</span> 
                                <input onkeyup="clearNoNum(this)" onafterpaste="clearNoNum(this)" value="10" style="font-size:18px;width:180px;float:left;border:none;border-bottom:5px solid #666;display:block;    color: #ff9b07;
    font-weight: bold;
    font-size: 22px;" id="recharge_money" />
                                <span style="display:block;float:left;font-size:18px;">元</span>
                            </p>
                            <div id="money_value" style="overflow: hidden;">
                                <span data-val="10" class="add_bg">￥10</span>
                                <span data-val="100">￥100</span>
                                <span data-val="300">￥300</span>
                                <span data-val="500">￥500</span>
                                <span data-val="1000">￥1000</span>
                                <span data-val="3000">￥3000</span>
                                <span data-val="5000">￥5000</span>
                                <span data-val="10000">￥10000</span>
                            </div>
                        </li>
                    </ul>
                    <div style="width:100%;height:auto;">
                    	<div style="width:240px;color:#000;line-height:40px;margin-right:10px;font-size:18px;margin:10px 0;margin-left:2%;">第二步：请点击选择存款通道</div>
                        <ul class="xzfs" id="xzfs">
                            {volist name="list" id="v" key="k"}
                            {if(2==$v['method'])}
                            <li data-controller="{$v['controller']}" data-id="{$v['id']}" data-method="{$v['method']}" data-key="{$v['type_value']}" data-ext="{$v['pay_name']}" {if(1==$k)} class="select" {/if}>
                            <h2>{$v['pay_name']}</h2>
                            <div style="font-size:12px;">
                                <span>线上支付</span>
                            </div>
                            </li >
                            {elseif(1==$v['method'])}
                            <li data-controller="{$v['controller']}" data-id="{$v['id']}" data-method="{$v['method']}" data-key="{$v['type_value']}" data-ext="{$v['pay_name']}" {if(1==$k)} class="select" {/if}>
                            <h2>{$v['type_name']}</h2>
                            <div style="font-size:12px;">
                                <span>{$v['pay_name']}</span>
                            </div>
                            </li>
                            {else/}
                            <li data-controller="{$v['controller']}" data-id="{$v['id']}" data-method="{$v['method']}" data-key="{$v['type_value']}" data-ext="{$v['pay_name']}" {if(1==$k)} class="select" {/if}>
                            <h2>{$v['type_name']}</h2>
                            <div style="font-size:12px;">
                                <span>{$v['pay_name']}(线下支付)</span>
                            </div>
                            </li>
                            {/if}
                            {/volist}
                        </ul>
                    </div>
                    <div style="margin:50px 0 20px;height:40px;">
                    	<a onClick="window.history.go(-1);" style="display:block;float:left;color:#fff;font-size:20px;text-align:center;border-radius:4px;height:45px;width:200px;margin-left:160px;line-height:45px;background:#e94335;font-weight: bold;">上一步</a>
                        <a onclick="toPay()" style="display:block;float:left;color:#fff;font-size:20px;text-align:center;border-radius:4px;height:45px;width:200px;line-height:45px;margin-left:100px;background:#e94335;font-weight: bold;" href="javascript:;">下一步</a>
                     </div>
                    <div id="content">
                    <div style="width:90%;height:auto; display:none;padding:30px;background:#fff;overflow: auto; " id="pay_online">
                    	<div style="width:18px;height:18px;background:url(__TEMPLATE__/mobile/index/img/close_gb.png);background-size:18px;position:absolute;top:15px;right:15px;" class="close"></div>
                        <div style="text-align:center;font-size:14px;">
                            <span style="color:#FF0000;display:block;margin:0 auto;width:100%;text-align: center;"> 充值账号：&nbsp;&nbsp;<i id="online_pay_name" style="font-style: normal;"></i></span>
                            <img id="online_pay_img" src="" style="margin-top:10px;" width="190"><br />
                            <span style="color:#FF0000;display:block;margin:0 auto;width:100%;text-align: center;" id="sm"></span>
                            <div style="width:100%;color:#FF0000;display:text-align: center;" id="online_djs">05分00秒失效</div>
                            <input style="display:block;margin:20px auto 10px;height:35px;width:265px;line-height:16px;" type="button" value="我已支付" class="btn btn-default btn-radius" id="online_button" onclick="window.location.reload();">
                        </div>
                    </div>
                    <div style="border-right:1px solid #ccc; display:none;padding:30px;background:#fff;  " id="off_bank">
                    	<div style="width:18px;height:18px;background:url(__TEMPLATE__/mobile/index/img/close_gb.png);background-size:18px;position:absolute;top:15px;right:15px;" class="close"></div>
                    	<div >
                            <span style="font-size:14px;line-height:30px;">银 行 名 称：&nbsp;&nbsp;<span id="bank_mc"></span></span><br />
                            <span style="font-size:14px; line-height:30px;">收 款 账 号：<span id="bank_num"></span>&nbsp;&nbsp;</span><br />
                            <span style="font-size:14px; line-height:30px;">收 款 姓 名：<span id="bank_name"></span>&nbsp;&nbsp;</span><br />
                        </div>
                        <p id="beizhu_bank" style="margin:10px 0;text-indent: 24px;color:#666;"></p>
                        <div class="money">
                            <label>
                                <em class="red">
                                    ＊
                                </em>
                                验证信息:
                            </label>
                            <div class="form">
                                <div class="form_group">
                                    <input type="text" placeholder="请填写您的银行卡号" name="bandno" required="required">
                                </div>
                            </div>
                        </div>
                        <div class="money">
                            <label>
                                <em class="red">
                                    ＊
                                </em>
                                存入时间:
                            </label>
                            <div class="form ">
                            	<div class="form_group ">
                            		<input type="text" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',onpicked: hide })"  required="required" class="banktime times">
                            	</div>
                               
                            </div>
                        </div>
                        
                        <input style="display:block;margin:20px auto 10px;height:35px;width:265px;line-height:16px;" type="button" value="提交" class="off_save btn btn-default btn-radius">
                    </div>
                    <div style="border-right:1px solid #ccc; display:none;background:#fff;padding:30px; " id="pay_offline">
                    	<div style="width:18px;height:18px;background:url(__TEMPLATE__/mobile/index/img/close_gb.png);background-size:18px;position:absolute;top:15px;right:15px;" class="close"></div>
                    	<div style="text-align: center;">
                            <img id="off_img" src="" width="200" height="200"><br />
                            <span style="color:#FF0000">收 款 <span id="off_lab"></span> 账 号：&nbsp;&nbsp;<span id="off_name"></span></span><br />
                        </div>
                        <p id="beizhu_zw_info" style="margin:10px 0;text-indent: 24px;color:#666;"></p>
                        <div class="money" style="margin-top:15px;">
                            <label>
                                <em class="red">
                                    ＊
                                </em>
                                验证信息:
                            </label>
                            <div class="form">
                                <div class="form_group">
                                    <input id="info_zfb_wx" type="text" placeholder="" name="words" required="required">
                                </div>
                            </div>
                        </div>
                        <div class="money">
                            <label>
                                <em class="red">
                                    ＊
                                </em>
                                存入时间:
                            </label>
                            <div class="form ">
                            	<div class="form_group ">
                            		<input type="text" placeholder="" required="required" class="offtime times" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' , onpicked: hide}); ">
                            	</div>
                               
                            </div>
                        </div>
                        
                        <input style="display:block;margin:20px auto 10px;height:35px;width:265px;line-height:16px;" type="button" value="提交" class="off_save btn btn-default btn-radius">
                    </div>
                </div>
               </div>
            </div>
        </div>
    </div>
</div>
<div id="pay_div"></div>
<script>
	$('#money_value').children('span').click(function() {
        var money_value = $(this).data('val');
        $('#money_value').children('span').removeClass('add_bg');
        $(this).addClass('add_bg');
        $('#recharge_money').val(money_value);
    });
    $('#xzfs').children('li').click(function() {
        $('#xzfs').children('li').removeClass('select');
        $('#xzfs').children('li').addClass('unselect');
        $(this).removeClass('unselect').addClass('select');
    });

    $('.off_save').click(function(){
    	if($(this).val()=='提交中') return;
    	$(this).val('提交中')
        var ext = $('.select').data('ext');
        var type = 0;
        console.log(ext);
        if( '微信扫码'==ext ){
            type = 1;
        }else if( '支付宝扫码'==ext ){
            type = 2;
        }else if( '银联转账'==ext ){
            type = 3;
        }else if( 'QQ扫码'==ext ){
            type = 4;
        }else{
            layer.msg("方案错误，请重试", {icon: 5});
            return;
        }
        var money = parseFloat($('#recharge_money').val());
        var account = $('.select').data('id');
        var data = '';
        if( 1==type || 2==type || 4==type ){
            data = {'type':type,'money':money,'remark':$('input[name="words"]').val(),'time':$(".offtime").val(),'account':account};
        }else if( 3==type ){
            data = {'type':type,'money':money,'remark':$('input[name="bandno"]').val(),'time':$(".banktime").val(),'account':account};
        }else{
            layer.msg('方案无效！', {icon: 5});
            return;
        }
        var index = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        $.ajax({
            type: "post",
            url: "{:url('mobile/member/offLineRecharge')}",
            data: data,
            success: function(ret) {
                ret = JSON.parse(ret);
                if( 1==parseInt(ret.status) ){
                    layer.msg("提交成功", {icon: 1});
                    setTimeout(function(){
                        window.location.reload();
                    },1000);
                }else{
                    layer.close(index);
                    layer.msg(ret.msg, {icon: 5});
                    $('.off_save').val('提交')
                }
            },error:function(){
                layer.close(index);
                layer.msg("通讯失败！", {icon: 5});
                $('.off_save').val('提交')
            }
        });
    });
    var interval_on = null;
    var interval = null;
    function toPay(){
        var username = '{$name}';
        var money = parseFloat($('#recharge_money').val());
        var method = $('.select').data('method');
        var index = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });

        if( 1==parseInt(method) ){
            //第三方
            
            var controller = $('.select').data('controller');
            var key = $('.select').data('key');

            $.ajax({
                type: "post",
                url: '/index/pay'+controller+'/initPay.html',
                data: {"username": username,"amount": money,"pay_type": key},
                success: function(data) {

                    if( 'string' == typeof (data) ){
                        data = JSON.parse(data);
                    }
                    var status = data.status;
                    if(status == '200') {
                        layer.close(index);
                        window.open(data.data,'_blank');
                    }else if( '201'==status ){
                        $('#pay_div').html(HTMLDecode(data.data));
                    }else {
                        var info = '';
                        if( data.hasOwnProperty('info') ){
                            info = data.info;
                        }else{
                            info = data.msg;
                        }
                        if( !info ){
                            info ="请求错误";
                        }
                        layer.msg(info, {icon: 5});
                        layer.close(index);
                    }
                }
            });
        }else if( 2==parseInt(method) ){
            //线上
            var way = $('.select').data('ext');
            var type = '';
            if( '微信扫码'==way ){
                type = "wechat";
                $('#sm').html('打开微信，扫码支付')
            }else{
                type = "alipay";
                $('#sm').html('打开支付宝，扫码支付')
            }
            $.ajax({
                type: "post",
                url: "{:url('index/pay/buildCode')}",
                data: {
                    'type':type,'money':money,'username':username
                },
                success: function(data) {
                    if(data.status=='200'){
                        $('#online_pay_img').attr('src','__CODE__/'+data.data.code);
                        if(interval_on) {
                            clearInterval(interval_on);
                        }
                        online_minute = "4";
                        online_second = "60";
                        interval_on = setInterval(beginInterval_on,1000);
                        layer.close(index);
                        $('.zzc_recharge').show();
                        $('#pay_online').show();
                    }else{
                        layer.close(index);
                        layer.msg(data.info, {icon: 5});
                    }
                }
            });
        }else if( 3==parseInt(method) ){
            var id = $('.select').data('id');
            $.ajax({
                type: "post",
                url: "{:url('mobile/member/getOfflineMessage')}",
                data: {id:id},
                success: function(data) {
                    data = JSON.parse(data);
                    if( 1==parseInt(data.status) ){
                        layer.close(index);
                        var off_info = data.data;
                        var off_wx = off_info.xx_weixin;
                        var off_ali = off_info.xx_zhifubao;
                        var off_bank = off_info.xx_wangyin;
                        var off_qq = off_info.xx_qq;
                        if(interval) {
                            clearInterval(interval);
                        }
                        beginInterval();
                        if( 1==parseInt(off_bank) ){
                            $('#bank_mc').html(off_info.xx_bankname);
                            $('#bank_num').html(off_info.xx_bankno);
                            $('#bank_name').html(off_info.xx_bankren);
                            $('#beizhu_bank').html(off_info.xx_remark);
                            layer.close(index);
                            $('.zzc_recharge').show();
                            $('#off_bank').show();
                        }else if(1==parseInt(off_wx) || 1==parseInt(off_ali) || 1==parseInt(off_qq)){
                        	if(1==parseInt(off_wx)){
                        		$('#info_zfb_wx').attr('placeholder','请输入您的微信账号')
                        	}else if(1==parseInt(off_ali)){
                                $('#info_zfb_wx').attr('placeholder','请输入您的支付宝账号')
                            }else{
                        		$('#info_zfb_wx').attr('placeholder','请输入您的QQ账号')
                        	}
                            $('#off_name').html(off_info.xx_test);
                            $('#off_img').attr('src','__ATTACHMENT__/'+off_info.xx_erweima);
                            $('#beizhu_zw_info').html(off_info.xx_remark);
                            layer.close(index);
                            $('.zzc_recharge').show();
                            $('#pay_offline').show();
                        }else {
                            layer.close(index);
                            layer.msg("未找到对应支付方案", {icon: 5});
                        }
                    }else{
                        layer.close(index);
                        layer.msg(data.msg, {icon: 5});
                    }
                }
            });
        }else{
            layer.msg('选择方案错误', {icon: 5});
        }
    }
    function beginInterval_on(){
        if(online_second=='01'&&online_minute=='00') {
            clearInterval(interval_on);
            $('#online_djs').html("已经失效，请重新选择");
            $('#online_button').val("关闭");
            return;
        }
        online_second--;
        if(online_minute=='4'){
            online_minute = "0" + online_minute;
        }
        if(online_minute=='0'){
            online_minute = "0" + online_minute;
        }
        if(online_second == '00') {
            online_second = 59;
            online_minute--;
            if(online_minute < 10) online_minute = "0" + online_minute;
        }
        if(online_second < 10) online_second = "0" + online_second;
        $('#online_djs').html(online_minute+'分'+online_second+'秒失效')
    }
    function beginInterval(){
        interval = setInterval(function() {
            var date = new Date();
            var year = date.getFullYear(); //当前年份
            var month = date.getMonth(); //当前月份
            var data = date.getDate(); //天
            var hours = date.getHours(); //小时
            var minute = date.getMinutes(); //分
            var second = date.getSeconds(); //秒
            var time = year + "-" + fnW((month + 1)) + "-" + fnW(data) + " " + fnW(hours) + ":" + fnW(minute) + ":" + fnW(second);
            $('.times').val(time);
        }, 1000);
    }
    function fnW(str) {
        var num;
        str > 9 ? num = str : num = "0" + str;
        return num;
    }
    function clearNoNum(obj){
        obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
        //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
        if( obj.value.indexOf(".") < 0 && obj.value != "" ){
            obj.value= parseFloat(obj.value);
        }
    }
    function HTMLDecode(text) {
        var temp = document.createElement("div");
        temp.innerHTML = text;
        var output = temp.innerText || temp.textContent;
        temp = null;
        return output;
    }
   $('.close').click(function(){
   	   $('.zzc_recharge').hide();
    	$('#pay_offline').hide();
    	$('#off_bank').hide();
    	$('#pay_online').hide();
   })
   
   function hide(){
   	 clearInterval(interval)
   }
</script>
</body>
